package com.kyxx.mycommonproject.shangpinshoucang;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.kyxx.mycommonproject.R;

public class FavGoodFragment extends Fragment {
    private ListView lv;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_fav_good, container, false);
        lv = (ListView) view.findViewById(R.id.lv);
        FavGoodAdapter favGoodAdapter = new FavGoodAdapter();
        lv.setAdapter(favGoodAdapter);
        return view;
    }

    class FavGoodAdapter extends BaseAdapter {
        @Override
        public int getCount() {
            return 20;
        }

        @Override
        public Object getItem(int i) {
            return null;
        }

        @Override
        public long getItemId(int i) {
            return 0;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {
            ViewHolder holder;
            if (view == null) {
                holder = new ViewHolder();
                view = View.inflate(getActivity(), R.layout.item_fav_good, null);
                holder.iv_good = (ImageView) view.findViewById(R.id.iv_good);
                holder.tv_name = (TextView) view.findViewById(R.id.tv_name);
                holder.tv_price = (TextView) view.findViewById(R.id.tv_price);
                holder.tv_more = (TextView) view.findViewById(R.id.tv_more);
                view.setTag(holder);
            } else {
                holder = (ViewHolder) view.getTag();
            }
            return view;
        }
    }

    public class ViewHolder {
        ImageView iv_good;
        TextView tv_name;
        TextView tv_price;
        TextView tv_more;
    }
}
